#include "pathandname.h"

#define MAX(a, b) ((a)>(b)?(a):(b))

PathAndName::PathAndName(QString pn)
{
    QStringList list = pn.split(".");
    if (list.length()<2){
        subname = "mpp";
    }else{
        subname = list[1];
    }
    QString s2 = list[0];
    int t1 = s2.lastIndexOf("/");
    int t2 = s2.lastIndexOf("\\");

    int t = MAX(t1, t2);
    path = s2.left(t+1);
    filename = s2.right(s2.size()-t-1);
}

QString PathAndName::getFilename()
{
    return filename;
}

QString PathAndName::getFilePath()
{
    return path;
}

QString PathAndName::getFileSubName()
{
    return subname;
}
